package com.gxa.modules.communityManagement.controller;



import com.gxa.modules.community.util.Result;
import com.gxa.modules.communityManagement.entity.HouseRent;
import com.gxa.modules.communityManagement.form.HouseRentForm;
import com.gxa.modules.communityManagement.service.HouseRentService;
import io.swagger.annotations.Api;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


@RestController
@Api(tags = "房屋出租管理")
public class HouseRentController {
    @Autowired
    private HouseRentService houseRentService;
    @ApiOperation("房屋出租管理查询")
    @PostMapping("/houseRent/list")
    public Result<List<HouseRent>> list(@RequestBody(required = false) HouseRent houseRent){
        List<HouseRent> houseRents = this.houseRentService.queryAll(houseRent);
        Result<List<HouseRent>> r= Result.success(houseRents);
        return r;
    }

    @ApiOperation("房屋出租管理 修改")
    @PutMapping("/houseRent/updateStatus")
    public Result updateStatus(@RequestBody HouseRentForm houseRentForm){
        this.houseRentService.updateStatus(houseRentForm);
        Result r= Result.success();
        return r;
    }

    @ApiOperation("房屋出租管理 添加")
    @PostMapping("/houseRent/add")
    public Result add(@RequestBody HouseRent houseRent){
        houseRent.setRentStatus("出租中");
        houseRent.setCollect("0");
        this.houseRentService.add(houseRent);
        Result r= Result.success();
        return r;
    }


}
